home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / VPOJAVA.DLL / SOURCE / ATTENTION_DIALOG < prev    next >
Text File  |  1998-12-10  |  3KB  |  117 lines

  1. import java.awt.*;
  2. import java.net.URL;
  3.  
  4. import symantec.itools.multimedia.ImageViewer;
  5. import symantec.itools.awt.util.dialog.ModalDialog;
  6.  
  7. public class AttentionDialog extends ModalDialog
  8. {
  9.     public AttentionDialog(Frame parent, String title, String message, URL iconURL)
  10.     {
  11.         super(parent, title);
  12.  
  13.         if (iconURL != null)
  14.         {
  15.             ImageViewer img = new ImageViewer(iconURL);
  16.             add(img);
  17.         }
  18.  
  19.         // This code is automatically generated by Visual Cafe when you add
  20.         // components to the visual environment. It instantiates and initializes
  21.         // the components. To modify the code, only use code syntax that matches
  22.         // what Visual Cafe can generate, or Visual Cafe may be unable to back
  23.         // parse your Java file into its visual environment.
  24.         //{{INIT_CONTROLS
  25.         setLayout(new FlowLayout(FlowLayout.LEFT,5,5));
  26.         setSize(270,73);
  27.         setVisible(false);
  28.         add(label1);
  29.         label1.setBounds(5,5,14,23);
  30.         okButton.setLabel("OK");
  31.         add(okButton);
  32.         okButton.setBackground(java.awt.Color.lightGray);
  33.         okButton.setBounds(24,5,31,23);
  34.         //}}
  35.  
  36.         label1.setText(message);
  37.  
  38.         //{{REGISTER_LISTENERS
  39.         SymAction lSymAction = new SymAction();
  40.         okButton.addActionListener(lSymAction);
  41.         //}}
  42.     }
  43.  
  44.     public AttentionDialog(Frame parent)
  45.     {
  46.         this(parent, "Attention", "Event", null);
  47.     }
  48.  
  49.     // Add a constructor for Interactions (ignoring modal)
  50.     public AttentionDialog(Frame parent, boolean modal)
  51.     {
  52.         this(parent);
  53.     }
  54.  
  55.     // Add a constructor for Interactions (ignoring modal)
  56.     public AttentionDialog(Frame parent, String message, boolean modal)
  57.     {
  58.         this(parent, "Attention", message, null);
  59.     }
  60.  
  61.     public void addNotify()
  62.     {
  63.           // Record the size of the window prior to calling parents addNotify.
  64.         Dimension d = getSize();
  65.  
  66.         super.addNotify();
  67.  
  68.         if (fComponentsAdjusted)
  69.             return;
  70.  
  71.         // Adjust components according to the insets
  72.         Insets insets = getInsets();
  73.         setSize(insets.left + insets.right + d.width, insets.top + insets.bottom + d.height);
  74.         Component components[] = getComponents();
  75.         for (int i = 0; i < components.length; i++)
  76.         {
  77.             Point p = components[i].getLocation();
  78.             p.translate(insets.left, insets.top);
  79.             components[i].setLocation(p);
  80.         }
  81.         fComponentsAdjusted = true;
  82.     }
  83.  
  84.     // Used for addNotify check.
  85.     boolean fComponentsAdjusted = false;
  86.  
  87.     //{{DECLARE_CONTROLS
  88.     java.awt.Label label1 = new java.awt.Label();
  89.     java.awt.Button okButton = new java.awt.Button();
  90.     //}}
  91.  
  92.     class SymAction implements java.awt.event.ActionListener
  93.     {
  94.         public void actionPerformed(java.awt.event.ActionEvent event)
  95.         {
  96.             Object object = event.getSource();
  97.             if (object == okButton)
  98.                 okButton_ActionPerformed(event);
  99.         }
  100.     }
  101.  
  102.     void okButton_ActionPerformed(java.awt.event.ActionEvent event)
  103.     {
  104.         // to do: code goes here.
  105.  
  106.         okButton_ActionPerformed_Interaction1(event);
  107.     }
  108.  
  109.     void okButton_ActionPerformed_Interaction1(java.awt.event.ActionEvent event)
  110.     {
  111.         try {
  112.             this.dispose();
  113.         } catch (Exception e) {
  114.         }
  115.     }
  116. }
  117.